<template>
  <div class="go_top_container" v-show="showImg">
    <p>返回顶部</p>
    <!-- <img @click="goTop" src="../assets/img/activity_3.png" alt=""> -->
  </div>
</template>

<script>
import { scrollToAppoint } from '@utils'
export default {
  data() {
    return {
      showImg: false
    }
  },
  mounted() {
    this.$nextTick(() => {
      window.addEventListener('scroll', this.scrollTop, true)
    })
  },
  methods: {
    goTop() {
      scrollToAppoint(500, '', 1)
    },
    scrollTop() {
      this.$nextTick(() => {
        let a = document.querySelector('#app').scrollTop
        this.showImg = a > 400
      })
    }
  }
}
</script>

<style lang="less" scoped>
.go_top_container{
  position: fixed;
  bottom: 80px;
  right: 0px;
  z-index: 1;
  img{
    width: 50px;
    transform: rotate(180deg);
  }
}
</style>